<?php

namespace app\common\library;

use app\common\model\UserTime;

class Remind
{
    public static function shangban($openid)
    {
        $where = [];
        $where['openid'] = $openid;
        $where['begin_time'] = ['<=', date('H:i:s', time())];
        $where['end_time'] = ['>=', date('H:i:s', time())];
        $res = UserTime::where($where)->find();
        if (!$res) {
            return '未找到符合的时间计划';
        }
        $message = '11';
        switch ($res['types']) {
            case '0':
                Queues::delay($res['remind_time'], 'remind', $res->toArray());
                $message = '提醒预计在' . date('H:i:s', time() + $res['remind_time']) . '进行';
                break;
            case '1':
                Queues::time($res['remind_time'], 'remind', $res->toArray());
                $message = '提醒预计在' . date('H:i:s', $res['remind_time']) . '进行';
                break;
        }
        return $message;
    }
}